#include "iterator.h"
#include <iostream>

using namespace iteratored;

std::string MenuItem::getName()
{
    return this->m_name;
}

std::string MenuItem::getDescription()
{
    return this->m_description;
}

bool MenuItem::getVegetarian()
{
    return this->m_vegetarian;
}

double MenuItem::getPrice()
{
    return this->m_price;
}

PancakeHouseMenu::PancakeHouseMenu()
{
    this->m_menuitems.push_back(MenuItem("K&B's Pancake Breakfast", "Pancakes with scrambled eggs, and toast", true, 2.99));
    this->m_menuitems.push_back(MenuItem("Regular Pancake Breakfast", "Pancakes with fried eggs, sausage", false, 2.99));
    this->m_menuitems.push_back(MenuItem("Blueberry Pancakes", "Pancakes made with fresh blueberries", true, 3.49));
    this->m_menuitems.push_back(MenuItem("Waffles", "Waffles, with your choice of blueberries or strawberries", true, 3.59));
}

Iterator* PancakeHouseMenu::createIterator()
{
    return new PancakeHouseMenuIterator(this->m_menuitems);
}

DinerMenu::DinerMenu()
{
    this->m_menuitems.push_back(MenuItem("Vegetarian BLT", "(Fakin') Bacon with lettuce & tomato on whole wheat", true, 2.99));
    this->m_menuitems.push_back(MenuItem("BLT", "Bacon with lettuce & tomato on whole wheat", false, 2.99));
    this->m_menuitems.push_back(MenuItem("Soup of the day", "Soup of the day, with a side of potato salad", false, 3.29));
    this->m_menuitems.push_back(MenuItem("Hotdog", "A hot dog, with saurkraut, relish, onions, topped with cheese", false, 3.05));
}

Iterator* DinerMenu::createIterator()
{
    return new DinerMenuIterator(this->m_menuitems);
}

PancakeHouseMenuIterator::PancakeHouseMenuIterator(std::vector<MenuItem> m)
{
    this->m_menuitems = m;
    this->pos = 0;
}

bool PancakeHouseMenuIterator::hasNext()
{
    if (this->pos >= this->m_menuitems.size())
    {
        return false;
    }

    return true;
}

MenuItem PancakeHouseMenuIterator::next()
{
    return this->m_menuitems[this->pos++];
}

DinerMenuIterator::DinerMenuIterator(std::vector<MenuItem> m)
{
    this->m_menuitems = m;
    this->pos = 0;
}

bool DinerMenuIterator::hasNext()
{
    if (this->pos >= this->m_menuitems.size())
    {
        return false;
    }

    return true;
}

MenuItem DinerMenuIterator::next()
{
    return this->m_menuitems[this->pos++];
}

Waitress::Waitress(Menu* p, Menu* d)
{
    this->m_pancake = p;
    this->m_diner = d;
}

void Waitress::PrintMenu()
{
     Iterator* i = this->m_pancake->createIterator();
     std::cout << "MENU\n----\nBREAKFAST" << std::endl;
     this->printMenu(i);
     i = this->m_diner->createIterator();
     std::cout << "\nLUNCH" << std::endl;
     this->printMenu(i);
}

void Waitress::printMenu(Iterator* i)
{
      while(i->hasNext())
      {
          MenuItem t = i->next();
          std::cout << t.getName() << ", ";
          std::cout << t.getPrice() << " -- ";
          std::cout << t.getDescription() << std::endl;
      }
}
